package com.lagou;

import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.springframework.stereotype.Component;

@Component
public class TomcatServer implements AbstractServletWebServerFactory{
    private static int PORT = 8080;
    private static String CONTEX_PATH = "/test";
    private static String SERVLET_NAME = "indexServlet1";
    private static String SERVLET_NAMET = "indexServletC";



    @Override
    public void createServer() throws Exception {
        Tomcat tomcat=new Tomcat();

        tomcat.setPort(PORT);
        tomcat.getHost().setAutoDeploy(false);
        tomcat.addWebapp("/","G:\\个人技术文件\\Java\\学习文档\\课程相关\\拉勾Java高薪训练营\\4.模块四 约定优于配置设计范式及Spring Boot源码剖析\\作业\\springboot_task\\tomcat.8080");

        StandardContext standardContex = new StandardContext();
        standardContex.setPath(CONTEX_PATH);

        // tomcat容器添加standardContex
        tomcat.getHost().addChild(standardContex);


        //tomcat.addWebapp("/","/");
        tomcat.start();

        // 异步进行接收请求
        tomcat.getServer().await();
        //tomcat.getServer().await();

    }






}
